<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>简易ATM</title>
    <script>
      let balance = 100
      for (;;) {
        let choice = prompt('请选择:\n1.存钱\n2.取钱\n3.显示余额\n4.退出')
        if (choice == 1) {
          let money = parseFloat(prompt('请您输入存钱金额: '))
          balance += money
          alert('存钱完成,当前余额为: ' + balance)
        } else if (choice == 2) {
          let money = parseFloat(prompt('请您输入取钱金额: '))
          if (balance - money < 0) {
            alert('对不起,您的余额不足...')
          } else {
            balance -= money
            alert('取钱完成,当前余额为: ' + balance)
          }
        } else if (choice == 3) {
          alert('当前余额为: ' + balance)
        } else if (choice == 4) {
          alert('谢谢使用...')
          break
        } else {
          alert('请您选择有误,请重新选择...')
        }
      }
      window.close()
    </script>
  </head>
  <body></body>
</html>
